# -*- coding:utf-8 -*-
import requests

from bs4 import BeautifulSoup


def get_mean(val):
    url = 'http://dict.youdao.com/jsonapi?jsonversion=2&client=mobile&q=%s&network=wifi' % val
    re = requests.get(url)
    js = re.json()
    means = js['video_sents']['word_info']['sense']
    s = ''
    for i in means:
        s += i
    return s


def get_mean2(val):
    url = 'http://apii.dict.cn/mini.php?q=%s' % val
    re = requests.get(url)
    soup = BeautifulSoup(re.text, features="html.parser")
    p_node = soup.find('div', id='e')
    if p_node is not None:
        return p_node.text
    return ''







'''
http://dict.youdao.com/jsonapi
jsonversion：json 版本，目前已知取值1或2，返回结果大同小异。本文档采用2
client：客户端类型，取值mobile
q：查询的单词
dicts：需要查询哪些字典。目前已知 {"count":99,"dicts":[["ec","ce","newcj","newjc","kc","ck","fc","cf","multle","jtj","pic_dict","tc","ct","typos","special","tcb","baike","lang","simple","wordform","exam_dict","ctc","web_search","auth_sents_part","ec21","phrs","input","wikipedia_digest","ee","collins","ugc","media_sents_part","syno","rel_word","longman","ce_new","le","newcj_sents","blng_sents_part","hh"],["ugc"],["longman"],["newjc"],["newcj"],["web_trans"],["fanyi"]]}。可为空，为空则返回全部字段
keyfrom：mdict. + 版本号 + .手机平台。可为空
model：手机型号。可为空
mid：平台版本。可为空
imei：未知。可为空
vendor：应用下载平台。可为空
screen：屏幕宽高。可为空
ssid：用户名。可为空
network：网络状态，取值 wifi、4G、5G 等
abtest：ab测试。可为空
xmlVersion：默认使用5.1

'''